﻿@using Furion
@using ST.Torch.WebApi.Web.Core;
@inherits UtilRazorPage<object>
@{

	string FileHttpApiUrl = App.Configuration["SysInfo:FileHttpApiUrl"];
		Layout = null;
}
<!DOCTYPE html>
<html>
<head>
	<title>Pear Admin 4.0</title>
	<meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<link rel="stylesheet" href="../PearAdmin/component/pear/css/pear.css" />
	<link rel="stylesheet" href="../PearAdmin/admin/css/admin.css" />
	<link rel="stylesheet" href="../PearAdmin/admin/css/admin.dark.css" />
	<link rel="stylesheet" href="../PearAdmin/admin/css/variables.css" />
	<link rel="stylesheet" href="../PearAdmin/admin/css/reset.css" />
</head>
<!-- 结 构 代 码 -->
<body class="layui-layout-body pear-admin">
	<!-- 布 局 框 架 -->
	<div class="layui-layout layui-layout-admin">
		<!-- 顶 部 样 式 -->
		<div class="layui-header">
			<!-- 菜 单 顶 部 -->
			<div class="layui-logo">
				<!-- 图 标 -->
				<img class="logo">
				<!-- 标 题 -->
				<span class="title"></span>
			</div>
			<!-- 顶 部 左 侧 功 能 -->
			<ul class="layui-nav layui-layout-left">
				<li class="collapse layui-nav-item"><a href="#" class="layui-icon layui-icon-shrink-right"></a></li>
				@* <li class="refresh layui-nav-item"><a href="#" class="layui-icon layui-icon-refresh-1" loading=600></a></li> *@
				<li class="refresh layui-nav-item"><a href="#" class="layui-icon layui-icon-refresh-1" loading=10></a></li>
			</ul>
			<!-- 多 系 统 菜 单 -->
			<div id="control" class="layui-layout-control"></div>
			<!-- 顶 部 右 侧 菜 单 -->
			<ul class="layui-nav layui-layout-right">
				<li class="layui-nav-item layui-hide-xs"><a href="#" class="menuSearch layui-icon layui-icon-search"></a></li>
				<li class="layui-nav-item layui-hide-xs message"></li>
				<li class="layui-nav-item layui-hide-xs"><a href="#" class="fullScreen layui-icon layui-icon-screen-full"></a></li>
				<li class="layui-nav-item user">
					<!-- 头 像 -->
					<a class="" href="javascript:;">@L("CurrentLang")</a>
					<!-- 功 能 菜 单 -->
					<dl class="layui-nav-child">
						<dd><a onclick="changeLanguage('zh-CN')">中文</a></dd>
						<dd><a onclick="changeLanguage('en-US')">English</a></dd>
						@* <dd><a href="/Home/LanguageSelect?Lang=zh-CN">中文</a></dd> *@
						@* <dd><a href="/Home/LanguageSelect?Lang=en-US">English</a></dd> *@
					
					</dl>
				</li>
				<li class="layui-nav-item user">
					<!-- 头 像 -->
					<a class="layui-icon layui-icon-username" href="javascript:;"></a>
					<!-- 功 能 菜 单 -->
					<dl class="layui-nav-child">
						<dd><a user-menu-url="/SYS/User/AddOrEdit?IsInfo=true" user-menu-id="5555123" user-menu-title="基本资料">@L("基本资料")</a></dd>
						<dd><a user-menu-url="/SYS/User/EditPass" user-menu-id="5555456" user-menu-title="修改密码">@L("修改密码")</a></dd>
						<dd><a href="javascript:void(0);" class="logout">@L("注销登录")</a></dd>
					</dl>
				</li>
				<!-- 主 题 配 置 -->
				<li class="layui-nav-item setting"><a href="#" class="layui-icon layui-icon-more-vertical"></a></li>
			</ul>
		</div>
		<!-- 侧 边 区 域 -->
		<div class="layui-side layui-bg-black">
			<!-- 菜 单 顶 部 -->
			<div class="layui-logo">
				<!-- 图 标 -->
				<img class="logo">
				<!-- 标 题 -->
				<span class="title"></span>
			</div>
			<!-- 菜 单 内 容 -->
			<div class="layui-side-scroll">
				<div id="side"></div>
			</div>
		</div>
		<!-- 视 图 页 面 -->
		<div class="layui-body">
			<!-- 内 容 页 面 -->
			<div id="content"></div>
		</div>
		<!-- 页脚 -->
		<div class="layui-footer layui-text"></div>
		<!-- 遮 盖 层 -->
		<div class="pear-cover"></div>
		<!-- 加 载 动 画 -->
		<div class="loader-wrapper">
			<!-- 动 画 对 象 -->
			<div class="loader"></div>
		</div>
	</div>
	<!-- 移 动 端 便 捷 操 作 -->
	<div class="pear-collapsed-pe collapse">
		<a href="#" class="layui-icon layui-icon-shrink-right"></a>
	</div>
	<!-- 翻译 -->
	<script>
		var GL_CloseAll='@L("关 闭 全 部")';
		var GL_CloseCurrent='@L("关 闭 当 前")';
		var GL_CloseOther='@L("关 闭 其 他")';
		var GL_CurrPageNoClosing='@L("当前页面不允许关闭")';
		var GL_CloseCurrent1='@L("关闭当前")';
		var GL_CloseOther1='@L("关闭其他")';
		var GL_CloseAll1='@L("关闭所有")';
	</script>
	<!-- 依 赖 脚 本 -->
	<script src="../PearAdmin/component/layui/layui.js"></script>
	<script src="../PearAdmin/component/pear/pear.js"></script>
    
    <script src="~/utils/cache.js"></script>
    <script src="~/utils/permission.js"></script>
	<!-- 框 架 初 始 化 -->
	<script>
		var $ = null;
		var button = null;
		var toast=null;
		var popup=null;
		layui.use(['admin', 'jquery', 'popup','button','toast'], function () {
			var admin = layui.admin;
			var tabPage = layui.popup;
			 $ = layui.jquery;
			 button = layui.button;
			 toast = layui.toast;
			  popup = layui.popup;
			console.log("initLayui")
			// yml | json | api
			//admin.setConfigurationPath("../PearAdmin/config/pear.config.json");
			//admin.setConfigurationPath("./PearConfig");
			admin.setConfigurationPath("@Html.Raw(@Url.Action("PearConfigyml", "Home", new { area = "" }))");
			
			window.changeLanguage = function (lan) {
				console.log("切换语言")
				console.log(tabPage)
				//tabPage.clear();
				admin.instances.tabPage.clear();
				window.location.href="/Home/LanguageSelect?Lang="+lan;
				//location.reload();
				
			}
			window.refreshUserInfo = function (lan) {
				$.ajax({
					type: 'Get',
					url: '/api/System/GetCurrUserInfo?Lang=' + lan,
					success: function (result) {
						setUserInfo(result.User);
						setPermissionKeys(result.PermissionIds);
					}
				});
			}
			FileHttpApiUrl='@FileHttpApiUrl';

			//刷新用户信息
			refreshUserInfo();
			// 渲染
			admin.render();


			// 注销
			admin.logout(function () {

				popup.success("@L("注销成功")", function () {
					location.href = "/Home/SignOut";
				})

				// 清空 tabs 缓存
				return new Promise((resolve) => {
					resolve(true)
				});
			});
			//--401登录过期处理--
			window.Handle401=function(){
				popup.failure("@L("登录过期")", function () {
					location.href = "/Home/SignOut";
				})
			}

			////全局请求错误处理--https://api.jquery.com/Ajax_Events/
			$(document).bind("ajaxError", function(res, textStatus, errorThrown){
				// do your function
				console.log(textStatus)
				console.log(errorThrown)
				console.log(res)
				// 处理错误
					if(textStatus.status==401){
						Handle401();
					}
					console.log("error", textStatus.responseText)
					var errorMsg=textStatus.responseText;
					var errorMsgSplit=textStatus.responseText.split('\r')[0].split(':')
					if(errorMsgSplit.length>1){
						errorMsg=errorMsgSplit[1]
					}
					toast.error({
							message: textStatus.status + ":" + errorMsg,
					});
			});
		
			//全局请求错误处理
			/*
			$.ajaxSetup({//全局请求错误处理设置
				error: function(res, textStatus, errorThrown) {
					// 处理错误
					if(res.status==401){
						Handle401();
					}
					toast.error({
							message: err.status + ":" + err.statusText,
					});
					// console.log(jqXHR)
					// console.log(textStatus)
					// console.log(errorThrown)
					// console.log('Ajax错误Index：', textStatus, errorThrown);
					// 可以根据jqXHR对象的属性进行更详细的错误处理
				}
			});
			*/
	
		})


	</script>
</body>
</html>